package com.aceitunaproject.server.combat;

/**
 * Represents the effects of a given combination of equipment,terrain or other
 * factors in the combat capability of an unit
 * 
 * @author Federico Bergstein
 * 
 */
public class CombatEffects {
	// These effects are only for testing, the actual combat system is yet to be
	// designed.
	private int attackerLethalityBonus = 0;
	private int attackerDefenseBonus = 0;
	private int defenderLethalityBonus = 0;
	private int defenderDefenseBonus = 0;

	public CombatEffects(int attackerLethalityBonus, int attackerDefenseBonus,
			int defenderLethalityBonus, int defenderDefenseBonus) {
		this.setAttackerLethalityBonus(attackerLethalityBonus);
		this.setAttackerDefenseBonus(attackerDefenseBonus);
		this.setDefenderLethalityBonus(defenderLethalityBonus);
		this.setDefenderDefenseBonus(defenderDefenseBonus);
	}

	// Adds two combat effect sets and returns the combination of the 2
	public static CombatEffects add(CombatEffects combatEffectsA,
			CombatEffects combatEffectsB) {

		CombatEffects result = new CombatEffects(combatEffectsA.getAttackerLethalityBonus()
				+ combatEffectsB.getAttackerLethalityBonus(), combatEffectsA.getAttackerDefenseBonus()
				+ combatEffectsB.getAttackerDefenseBonus(),
				combatEffectsA.getDefenderLethalityBonus()
				+ combatEffectsB.getDefenderLethalityBonus(), combatEffectsA.getDefenderDefenseBonus()
				+ combatEffectsB.getDefenderDefenseBonus()		
		);

		return result;
	}

	@Override
	public boolean equals(Object anObject) {
		if (!super.equals(anObject)) {
			if (anObject instanceof CombatEffects) {

				CombatEffects comparisonObject = (CombatEffects) anObject;

				return (this.getAttackerLethalityBonus() == comparisonObject.getAttackerLethalityBonus() && this.getAttackerDefenseBonus() == comparisonObject.getAttackerDefenseBonus() && this.getDefenderLethalityBonus() == comparisonObject.getDefenderLethalityBonus() && this.getDefenderDefenseBonus() == comparisonObject.getDefenderDefenseBonus());

			} else {
				return false;
			}
		} else {
			return true;
		}

	}

	/**
	 * @param attackerLethalityBonus the attackerLethalityBonus to set
	 */
	private void setAttackerLethalityBonus(int attackerLethalityBonus) {
		this.attackerLethalityBonus = attackerLethalityBonus;
	}

	/**
	 * @return the attackerLethalityBonus
	 */
	public int getAttackerLethalityBonus() {
		return attackerLethalityBonus;
	}

	/**
	 * @param attackerDefenseBonus the attackerDefenseBonus to set
	 */
	public void setAttackerDefenseBonus(int attackerDefenseBonus) {
		this.attackerDefenseBonus = attackerDefenseBonus;
	}

	/**
	 * @return the attackerDefenseBonus
	 */
	public int getAttackerDefenseBonus() {
		return attackerDefenseBonus;
	}

	/**
	 * @param defenderLethalityBonus the defenderLethalityBonus to set
	 */
	public void setDefenderLethalityBonus(int defenderLethalityBonus) {
		this.defenderLethalityBonus = defenderLethalityBonus;
	}

	/**
	 * @return the defenderLethalityBonus
	 */
	public int getDefenderLethalityBonus() {
		return defenderLethalityBonus;
	}

	/**
	 * @param defenderDefenseBonus the defenderDefenseBonus to set
	 */
	public void setDefenderDefenseBonus(int defenderDefenseBonus) {
		this.defenderDefenseBonus = defenderDefenseBonus;
	}

	/**
	 * @return the defenderDefenseBonus
	 */
	public int getDefenderDefenseBonus() {
		return defenderDefenseBonus;
	}

	

}
